package com.hengpeng.itfinbase.persist;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;

import com.hengpeng.common.web.annotation.HtmlInput;
import com.hengpeng.common.web.annotation.HtmlInputPattern;
import com.hengpeng.common.web.annotation.HtmlInputType;
import com.hengpeng.itfinbase.idAssign.AbstractAssign18IdEntity;
import com.hengpeng.itfinbase.persist.SmsPartner.SmsSendType;

/**
 * <pre>
 * 短信记录信息
 * </pre>
 * @author zhaojitao
 * @version 20150514
 */
@Entity
public class SmsLog extends AbstractAssign18IdEntity
{
	/**
	 * <pre>
	 * 发送状态
	 * </pre>
	 * @author chenhui
	 * @version 1.0, 2010-7-19
	 */
	public enum SmsLogState
	{
		FAILURE("发送失败"),
		/**
		 * 已发送
		 */
		SENDED("已发送"),
		/**
		 * 正在发送
		 */
		SENDING("正在发送"),

		/**
		 * 等待发送
		 */
		WAITING("等待发送");

		private String text;

		SmsLogState(String text)
		{
			this.text = text;
		}

		public String getText()
		{
			return text;
		}

		public void setText(String text)
		{
			this.text = text;
		}
	}
	
	/**
	 * <pre>
	 * 短信业务类型,在没指定发送优先级的时候,优先与短信类型来决定优先级
	 * </pre>
	 */
	public enum SmsLogTransType
	{
		/**
		 * 通知
		 */
		NOTICE("通知", 3),
		/**
		 * 促销
		 */
		PROMOTION("促销", 1),
		/**
		 * 支付
		 */
		IMPREST("支付", 4),
		/**
		 * 提款
		 */
		DRAW("提款", 4),
		/**
		 * 手机验证
		 */
		VALID("手机验证", 4),
		/**
		 * 告警
		 */
		WARN("告警", 5),
		/**
		 * 其他
		 */
		OTHER("其他", 1);

		private String text;

		private int value;

		SmsLogTransType(String text, int value)
		{
			this.text = text;
			this.value = value;
		}

		public String getText()
		{
			return text;
		}

		public int getValue()
		{
			return value;
		}
	}

	/**
	 * 发送类型
	 */
	public enum SmsSendState
	{
		/**
		 * 立即发送
		 */
		IMMEDIATELY("立即发送", 1),
		/**
		 * 定时发送
		 */
		SCHEDULED("定时发送", 2);

		private String text;

		private int value;

		private SmsSendState(String text, int value)
		{
			this.text = text;
			this.value = value;
		}

		public String getText()
		{
			return text;
		}

		public int getValue()
		{
			return value;
		}

		public void setText(String text)
		{
			this.text = text;
		}

		public void setValue(int value)
		{
			this.value = value;
		}

	}

	private static final long serialVersionUID = -5373578539418642184L;

	@HtmlInput(label = "用户名", type = HtmlInputType.TEXT, index = 2, nullable = true)
	@Column(length = 20)
	private String userName;

	@HtmlInput(label = "内容", type = HtmlInputType.TEXT, index = 2, nullable = true)
	@Column(length = 1000)
	private String content;

	@HtmlInput(label = "失败原因", type = HtmlInputType.HIDDEN, index = 8, nullable = true)
	@Column(length = 100)
	private String message;

	@HtmlInput(label = "手机号", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.MOBILE, index = 1, nullable = false)
	@Column(length = 20)
	private String mobile;

	@HtmlInput(label = "通道编号", type = HtmlInputType.HIDDEN, index = 8, nullable = true)
	@Column(length = 20)
	private Long partnerId;

	@HtmlInput(label = "重发次数", type = HtmlInputType.TEXT, index = 3, nullable = true)
	private Integer retryCount;

	@HtmlInput(label = "定时发送时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 12, nullable = true)
	private Date scheduledTime;// 定时发送时间

	@HtmlInput(label = "发送优先级", type = HtmlInputType.TEXT, index = 10, nullable = true, tips = "发送优先级，越大优先级越高，1~5，一般为2")
	@Column(length = 10)
	private Integer sendPriority;

	@HtmlInput(label = "发送类型", type = HtmlInputType.SELECT, index = 11, nullable = false, labelProperty = "text", tips = "立即发送或者排队发送")
	@Column(length = 20)
	@Enumerated(javax.persistence.EnumType.STRING)
	private SmsSendState sendState;

	@HtmlInput(label = "发送时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 6, nullable = false)
	private Date sendTime;

	@HtmlInput(label = "最晚发送时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 6, nullable = true)
	private Date expireTime;

	@Column(length = 20)
	@Enumerated(javax.persistence.EnumType.STRING)
	@HtmlInput(label = "网关类型", type = HtmlInputType.SELECT, index = 11, nullable = false, labelProperty = "text")
	private SmsSendType smsSendType;

	@HtmlInput(label = "状态", type = HtmlInputType.SELECT, index = 4, nullable = false, labelProperty = "text")
	@Column(length = 20)
	@Enumerated(javax.persistence.EnumType.STRING)
	private SmsLogState state;

	@HtmlInput(label = "成功时间", type = HtmlInputType.TEXT, pattern = HtmlInputPattern.DATETIME, format = "yyyy-MM-dd HH:mm", index = 7, nullable = true)
	private Date successTime;

	@HtmlInput(label = "业务类型", type = HtmlInputType.SELECT, index = 17, nullable = false, labelProperty = "text", tips = "区分不同业务")
	@Column(length = 20)
	@Enumerated(javax.persistence.EnumType.STRING)
	private SmsLogTransType transType;

	@HtmlInput(label = "接收人优先级", type = HtmlInputType.HIDDEN, index = 8, nullable = true, tips = "接收人优先级，越大优先级越高，1~99，一般为1")
	@Column(length = 10)
	private Integer userPriority = 1;



	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public String getMessage()
	{
		return message;
	}

	public void setMessage(String message)
	{
		this.message = message;
	}

	public String getMobile()
	{
		return mobile;
	}

	public void setMobile(String mobile)
	{
		this.mobile = mobile;
	}

	public Long getPartnerId()
	{
		return partnerId;
	}

	public void setPartnerId(Long partnerId)
	{
		this.partnerId = partnerId;
	}

	public Integer getRetryCount()
	{
		return retryCount;
	}

	public void setRetryCount(Integer retryCount)
	{
		this.retryCount = retryCount;
	}

	public Date getScheduledTime()
	{
		return scheduledTime;
	}

	public void setScheduledTime(Date scheduledTime)
	{
		this.scheduledTime = scheduledTime;
	}

	public Integer getSendPriority()
	{
		return sendPriority;
	}

	public void setSendPriority(Integer sendPriority)
	{
		this.sendPriority = sendPriority;
	}

	public SmsSendState getSendState()
	{
		return sendState;
	}

	public void setSendState(SmsSendState sendState)
	{
		this.sendState = sendState;
	}

	public Date getSendTime()
	{
		return sendTime;
	}

	public void setSendTime(Date sendTime)
	{
		this.sendTime = sendTime;
	}

	public Date getExpireTime()
	{
		return expireTime;
	}

	public void setExpireTime(Date expireTime)
	{
		this.expireTime = expireTime;
	}

	public SmsSendType getSmsSendType()
	{
		return smsSendType;
	}

	public void setSmsSendType(SmsSendType smsSendType)
	{
		this.smsSendType = smsSendType;
	}

	public SmsLogState getState()
	{
		return state;
	}

	public void setState(SmsLogState state)
	{
		this.state = state;
	}

	public Date getSuccessTime()
	{
		return successTime;
	}

	public void setSuccessTime(Date successTime)
	{
		this.successTime = successTime;
	}

	public SmsLogTransType getTransType()
	{
		return transType;
	}

	public void setTransType(SmsLogTransType transType)
	{
		this.transType = transType;
	}

	public Integer getUserPriority()
	{
		return userPriority;
	}

	public void setUserPriority(Integer userPriority)
	{
		this.userPriority = userPriority;
	}

}